var express = require('express');
var router = express.Router();
let fs = require('fs');
const path = require('path')
const mysql = require('mysql')
const connection = mysql.createPool({
  host: '127.0.0.1',
  user: 'root',
  password: 'root',
  // 数据库名称
  database: 'markdown'
})


/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.get('/gethtml', (req, res) => {
  const sql = 'select * from md'

  connection.query(sql, [], (err, results) => {
    if (err) throw err;
    res.send({
      err_code: 0,
      message: results
    })
  })
})


router.get('/gethtml', (req, res) => {
  const sql = 'select * from md'

  connection.query(sql, [], (err, results) => {
    if (err) throw err;
    res.send({
      err_code: 0,
      message: results
    })
  })
})
module.exports = router;
